package calorie.com.calorie.contact;
import android.util.Log;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.request.BaseRequest;
import calorie.com.calorie.response.ResultDTO;
import retrofit2.Call;
import retrofit2.Response;

public class UpgradeContact {
    public static class UpgradeContactPresent {
        private IUpgradeContact iUpgradeContact;

        public UpgradeContactPresent(IUpgradeContact iUpgradeContact) {
            this.iUpgradeContact = iUpgradeContact;
        }

        public void getUpgradeInfo() {
            ApiService service = ServiceGenerator.createService(ApiService.class);
            BaseRequest request = new BaseRequest();
            service.getAndroidVersion(request).enqueue(new NetCallBack<ResultDTO>() {
                @Override
                public void onSuccess(Call<ResultDTO> call, Response<ResultDTO> response) {
                    if (iUpgradeContact != null) {
                        iUpgradeContact.getVersionResult(response);
                    }
                }

                @Override
                public void onFailed() {
                    Log.e("error", "服务器异常");
                }
            });
        }

    }

    public interface IUpgradeContact extends IBaseView {
        public void getVersionResult(Response<ResultDTO> response);
    }
}
